package com.muki.spider.core;

import org.apache.log4j.Logger;

/**
 * uri队列监听内核
 * @author ljh_2017
 *
 */
public class UriRegisterationCore {

	private final Logger log = Logger.getLogger(UriRegisterationCore.class);
	private final UriQueueManagerPool pool = UriQueueManagerPool.getInstance();
	
	//负责控制过滤接口
	private FilterChain chain = new FilterChain();
	
	//单例模式
	private final static UriRegisterationCore core = new UriRegisterationCore();

	public static UriRegisterationCore getInstance() {
		return core;
	}

	/**
	 * @param uri
	 */
	public void receive(RequestUri uri) {
		chain.doFilter(uri);
		chain.FilterLoader(uri);
		if(uri.check()) {
			String topic = uri.getFlagUri().getTopic();
			String url = uri.getFlagUri().getUri();
			int depth = uri.getFlagUri().getDepth();
			log.info(topic+" | "+url+" | "+depth);
			pool.putUrl(topic, url+","+depth);
		}
	}
	
}
